       IDENTIFICATION DIVISION.
       PROGRAM-ID.
       ENVIRONMENT DIVISION.
       CONFIGURATION SECTION.
       
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01 MATA. 
	 02 ROWA   OCCURS 5 TIMES.
          03 COLA  OCCURS 5 TIMES.
	    04 AM  PIC 99.
       01 MATB. 
	 02 ROWB   OCCURS 5 TIMES.
	  03 COLB  OCCURS 5 TIMES.
	   04 BM   PIC 99.
       01 RES. 
	 02 ROWR   OCCURS 5 TIMES.
          03 COLR  OCCURS 5 TIMES.
           04 RM   PIC 99.
       77 R    PIC 9.
       77 C    PIC 9.
       77 I    PIC 9 VALUE IS 0.
       77 J    PIC 9 VALUE IS 0.
       77 ROWN PIC 99.
       77 COLN PIC 99.
       77 TEMP PIC ZZ.
       77 CH    PIC X.

       PROCEDURE DIVISION.
       MAIN.    
           DISPLAY "------ MATRIX ADDITION ------".
           PERFORM GETMATRIX.
           PERFORM ADDMATRIX.
           PERFORM DISPMAT.
           STOP RUN.

       GETMATRIX.    
           DISPLAY (LIN, COL) "ROWS   : ".
           ACCEPT R.
           DISPLAY (LIN, COL) "COLUMNS: ".
           ACCEPT C.        
           DISPLAY "------- MATRIX 1 -------- ".
           MOVE 4 TO LIN.
           PERFORM GETMAT1 VARYING I FROM 1 BY 1 UNTIL I > R.
           ADD 1 TO LIN.
           MOVE 1 TO COL.
           DISPLAY (LIN, COL) "------- MATRIX 2 -------- ".
           MOVE R TO LIN.
           ADD 5 TO LIN.
           PERFORM GETMAT2 VARYING I FROM 1 BY 1 UNTIL I > R.
       
       GETMAT1.
           ADD 1 TO LIN.
           MOVE 2 TO COL.
           PERFORM MTA VARYING J FROM 1 BY 1 UNTIL J > C.
       MTA.
           ADD 2 TO COL.
           ACCEPT (LIN, COL) AM(I, J).
       GETMAT2.
           ADD 1 TO LIN.
           MOVE 2 TO COL.
           PERFORM MTB VARYING J FROM 1 BY 1 UNTIL J > C.
       MTB. 
           ADD 2 TO COL.
           ACCEPT (LIN, COL) BM(I, J).
       ADDMATRIX.
           PERFORM ADM VARYING I FROM 1 BY 1 UNTIL I > R.
       ADM.
           PERFORM ADDMAT VARYING J FROM 1 BY 1 UNTIL J > C.
       ADDMAT.
           COMPUTE RM(I, J) = AM(I, J) + BM(I, J).
       
       DISPMAT.
	   ADD 1 TO LIN.
           MOVE 1 TO COL.
           DISPLAY (LIN, COL) "-------RESULT--------".
           MOVE 12 TO LIN.
           PERFORM DISROW VARYING I FROM 1 BY 1 UNTIL I > R.
	   ACCEPT CH.
       DISROW.
           MOVE 3 TO COL.
           PERFORM DISP VARYING J FROM 1 BY 1 UNTIL J > C.
           ADD 1 TO LIN.
       DISP.    
           MOVE RM(I, J) TO TEMP
           DISPLAY (LIN, COL) TEMP.
           ADD 3 TO COL.


